package com.wc.AlgoOJ_train.train5_数据结构.c1_线性表.DS0202_合并链表;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/1/29 22:23
 * @description http://43.138.190.70:8888/p/DS0202
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 100010, M = 100010;
    static int[] a = new int[N];
    static int[] b = new int[N];
    static int[] c = new int[N + M];
    static int n, m;

    public static void main(String[] args) {
        n = sc.nextInt();
        m = sc.nextInt();
        for (int i = 1; i <= n; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 1; i <= m; i++) {
            b[i] = sc.nextInt();
        }
        int idx1 = 1;
        int idx2 = 1;
        int idx3 = 1;
        while (idx1 <= n && idx2 <= m) {
            if (a[idx1] < b[idx2]) {
                c[idx3++] = a[idx1++];
            } else {
                c[idx3++] = b[idx2++];
            }
        }
        while (idx1 <= n) {
            c[idx3++] = a[idx1++];
        }
        while (idx2 <= m) {
            c[idx3++] = b[idx2++];
        }
        for (int i = 1; i < idx3; i++) {
            out.print(c[i]);
            out.print(' ');
        }
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
